<?php

namespace Goods\Model;
use Think\Model;

class GoodsModel extends Model
{
   protected  $pk='gid';
    protected $tableName='goods';
    /**
     * 商品添加
     */
    public function add($data){
//        dd($data);die;
       $res=M('goods')->add($data);
        if($res){
            return ['valid'=>$res,'msg'=>'发布成功'];
        }else{
            return ['valid'=>0,'msg'=>'发布失败'];
        }
    }
    /**
     * 商品编辑
     */
    public  function edit($data){
        $res=M('goods')->save($data);
        if($res){
            return ['valid'=>1,'msg'=>'发布成功'];
        }else{
            return ['valid'=>0,'msg'=>'发布失败'];
        }
    }
}